<template>
  <div class="shopDetails-wrap">
    <!-- 图片详情 -->
    <div class="shopShow">
      <div class="w">
        <el-card class="shopLis clearfix">
          <div class="shopPicLis">
            <div class="pic-type">
              <a href="javascript:;"
                 v-for="item in shopDetailLis.productImageSmall"
                 :key="item.productId">
                <img v-lazy="item"
                     alt="">
              </a>
            </div>
            <div class="pic-show">
              <img :src="shopDetailLis.productImageBig"
                   alt="">
            </div>
          </div>
          <div class="described clearfix">
            <h2>{{shopDetailLis.productName}}</h2>
            <div class="desc">{{shopDetailLis.subTitle}}<span class="price">￥ {{Number(shopDetailLis.salePrice).toFixed(2)}}</span></div>
            <div class="num">
              <span class="cart">
                <b class="number">数量</b>
                <a href="javascript:;"
                   class="sub">-</a>
                <input type="text"
                       class="numShow"
                       v-model="showNum">
                <a href="javascript:;"
                   class="add">+</a>
              </span>
            </div>
            <div class="shopBtn">
              <el-button type="primary">加入购物车</el-button>
              <el-button>现在购买</el-button>
            </div>
          </div>
        </el-card>
      </div>
    </div>
    <!-- 商品banner -->
    <div class="w">
      <el-card class="product-message">
        <div class="banner-shop">
          <div class="title">
            产品信息
          </div>
          <div class="banner-show"
               v-html="shopDetailLis.detail"
               v-if="shopDetailLis.detail">
          </div>
          <div class="banner-show"
               v-else>
            <p class="noDetail">暂无详细图片</p>
          </div>
        </div>
      </el-card>
    </div>
    <!-- footer -->
    <footer-items></footer-items>

  </div>
</template>
<script>
import FooterItems from '../../components/common/footer'
export default {
  components: {
    FooterItems
  },
  created() {
    this.getShopDetails()
  },
  data() {
    return {
      showNum: 1,
      //   存储商品详情数据
      shopDetailLis: []
    }
  },
  methods: {
    async getShopDetails() {
      try {
        const res = await this.$http.get(
          `/api/goods/productDet?productId=${this.$route.query.productId}`
        )
        if (res.status === 200) {
          this.shopDetailLis = res.data
        }
      } catch (error) {
        console.log(error)
      }
    }
  }
}
</script>

<style lang="less" scoped>
.shopLis {
  height: 562px;
  padding: 60px;
  .shopPicLis {
    width: 520px;
    float: left;
    .pic-type {
      float: left;
      width: 80px;
      a {
        display: block;
        height: 80px;
        width: 80px;
        border: 1px solid #ccc;
        border-radius: 10px;
        padding: 12px;
        margin-bottom: 15px;
        img {
          height: 54px;
          width: 54px;
        }
      }
    }
    .pic-show {
      float: left;
      img {
        height: 440px;
        width: 440px;
      }
    }
  }
  .described {
    float: left;
    width: 450px;
    position: relative;
    h2 {
      font-size: 24px;
      margin-bottom: 15px;
      color: #000;
    }
    .desc {
      display: block;
      font-size: 14px;
      color: #bdbdbd;
      margin-bottom: 10px;
      overflow: hidden;
      .price {
        color: red;
        font-size: 24px;
        float: right;
        vertical-align: middle;
      }
    }
    .num {
      height: 79px;
      width: 450px;
      border-top: 1px solid #ccc;
      border-bottom: 1px solid #ccc;
      position: relative;
      .cart {
        position: absolute;
        bottom: 10px;
        .number {
          margin-right: 10px;
        }
      }
      .numShow {
        width: 36px;
        height: 18px;
        text-align: center;
        border: none;
        margin: 0 5px;
      }
      .add,
      .sub {
        width: 34px;
        height: 37px;
        display: inline-block;
        line-height: 37px;
        text-align: center;
        border-radius: 50%;
        box-shadow: 1px 1px 10px rgba(0, 0, 0, 0.3);
        font-size: 14px;
        color: #999;
      }
    }
    .shopBtn {
      margin: 25px 0 10px 0;
      .el-button {
        width: 145px;
        height: 50px;
      }
    }
  }
}
.product-message {
  margin-top: 20px;
}
.title {
  height: 60px;
  width: 100%;
  border-radius: 8px 8px 0 0;
  line-height: 60px;
  padding-left: 15px;
  font-size: 18px;
  color: #626262;
  background: linear-gradient(#fbfbfb, #ececec);
  overflow: hidden;
  font-weight: 550;
}
.banner-show {
  img {
    width: 100%;
  }
  .noDetail {
    text-align: center;
    font-size: 30px;
    line-height: 100px;
    color: #ccc;
  }
}
</style>
